package com.swak.boot.config.vertx;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.swak.annotation.Flux;
import com.swak.redis.RedisCacheManager;
import com.swak.vertx.cache.GlobalCacheService;
import com.swak.vertx.cache.GlobalCacheService.GlobalCacheStorage;
import com.swak.vertx.cache.SecurityCacheService;
import com.swak.vertx.cache.SecurityCacheService.SecurityCacheStorage;
import com.swak.vertx.transport.server.ReactiveServer;

/**
 * 缓存配置
 * 
 * @author lifeng
 */
@Configuration
@ConditionalOnClass({ ReactiveServer.class, RedisCacheManager.class })
public class CacheAutoConfiguration {

	/**
	 * 全局的缓存存储器
	 * 
	 * @return
	 */
	@Bean
	@Flux(GlobalCacheStorage.class)
	public GlobalCacheStorage globalCacheStorage() {
		return new GlobalCacheStorage();
	}

	/**
	 * 全局的缓存存储器
	 * 
	 * @return
	 */
	@Bean
	public GlobalCacheService globalCacheService() {
		return new GlobalCacheService();
	}

	/**
	 * 安全信息的缓存存储器
	 * 
	 * @return
	 */
	@Bean
	@Flux(SecurityCacheStorage.class)
	public SecurityCacheStorage SecurityCacheStorage() {
		return new SecurityCacheStorage();
	}

	/**
	 * 安全信息的缓存存储器
	 * 
	 * @return
	 */
	@Bean
	public SecurityCacheService securityCacheService() {
		return new SecurityCacheService();
	}
}